package top.laoshuzi.server.common.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class ResponseResult<T> {
    private boolean isSuccess;
    private ResponseError error;
    private T result;

    public static final <T> ResponseResult<T> successed(T t) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setSuccess(true);
        result.setResult(t);
        return result;
    }

    public static final ResponseResult failed(ResponseError error) {
        ResponseResult result = new ResponseResult<>();
        result.setSuccess(false);
        result.setError(error);
        return result;
    }
}

